{
	template:`
    <m-page @back="back" :title="title">
        <m-top></m-top>
        <m-title>{{title}}
			<template #action>
				<m-button @click="addPageSettle(params.settleOid)">添加本页</m-button>
			</template>
        </m-title>
		<m-top></m-top>
		<m-list ref="list" :url="url" :params="params" :bottom="0" :search="search">
			<template #item="{item}">
				<m-card join>
                    <div class="flex padding-sm align-center">
                        <div class="flex-sub">
                            <div class="flex align-center">
                                <div class="cu-tag radius" :class="'bg-'+item.order.inputStore.color">{{item.order.inputStore.name}}</div>
                                <div class="flex-sub padding-left-sm">
                                    订单：{{item.order.orderNo}}
                                    <div class="text-sm">{{formatDate(item.order.accountDate,'yyyy-MM-dd HH:mm')}}</div>
                                </div>
                            </div>
                            <div class="flex align-center margin-top-xs">
                                <div class="cu-tag radius" :class="'bg-'+item.recharge.inputStore.color">{{item.recharge.inputStore.name}}</div>
                                <div class="flex-sub padding-left-sm">充值：{{item.recharge.orderNo}}</div>
                            </div>
                        </div>
                        <div class="text-sm text-right">
                            <div>付款：<span class="text-df text-red">{{item.order.inputStore.oid==params.inputStoreOid?'+':'-'}}{{formatAmount(item.payAmount)}}</span>元</div>
                            <div>赠送：<span class="text-df text-red">{{item.order.inputStore.oid==params.inputStoreOid?'+':'-'}}{{formatAmount(item.giveAmount)}}</span>元</div>
                            <div class="padding-top-xs">
                                <m-button v-if="item.settle.oid==params.settleOid" size="sm" @click="removeSettle(item)" type="warn">取消结算</m-button>
                                <m-button v-else size="sm" @click="addSettle(item,params.settleOid)" type="success">添加结算</m-button>
                            </div>
                        </div>
                    </div>
				</m-card>
			</template>
		</m-list>
    </m-page>
	`,
	props: ['param','parentVue'],
	data:function(){
		return {
            title:'选择结算明细',
            url:'action/order/rechargeOffset/getAddSettleList',
            params:{settleOid:'',inputStoreOid:'',settleStoreOid:''},
            search:[
                {title:'订单账期',name:'member.inputDate',input:'dateRange'}
            ]
		};
	},
	mounted(){
	    this.params.settleOid=this.param.settleOid;
	    this.params.inputStoreOid=this.param.inputStoreOid;
	    this.params.settleStoreOid=this.param.settleStoreOid;
	},
	methods:{
	    addSettle:function(item,settleOid){
            this.requestData('action/order/rechargeOffset/addSettle',
                {oids:[item.oid],settleOid:settleOid},
                (data)=>{
                    if(data.code==0){
                        this.remind().success(data.msg);
                        item.settle={oid:settleOid};
                    }else{
                        this.remind().error(data.msg);
                    }
                }
            );
	    },
	    addPageSettle:function(settleOid){
	        let ls=this.$refs.list.getList();
	        let oids=[];
	        for(let i=0;i<ls.length;i++){
	            oids.push(ls[i].oid);
	        }
            this.requestData('action/order/rechargeOffset/addSettle',
                {oids:oids,settleOid:settleOid},
                (data)=>{
                    if(data.code==0){
                        this.remind().success(data.msg);
                        this.$refs.list.refresh();
                    }else{
                        this.remind().error(data.msg);
                    }
                }
            );
	    },
	    removeSettle:function(item){
            this.requestData('action/order/rechargeOffset/removeSettle',
                {oid:item.oid},
                (data)=>{
                    if(data.code==0){
                        this.remind().success(data.msg);
                        item.settle={};
                    }else{
                        this.remind().error(data.msg);
                    }
                }
            );
	    },
	}
}